import os,sys
sys.path.append(os.path.dirname(sys.path[0]))
from fastapi import APIRouter,status,HTTPException,Request
from db.db_operate import kinetica
from models.collections import create_collections
import json

root_api = APIRouter()


@root_api.get("/")
def get_root(request:Request):
    
    try:
        host = request.url.hostname
        port = request.url.port
        response=kinetica.get_collections()
        ccs=create_collections(response,host,port).create_root()
        
        return ccs
    except:
        raise HTTPException(status_code=status.HTTP_404_NOT_FOUND)
        





